package com.xspace.android.imcommon.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class ImPreferences {
	private SharedPreferences mCfgPrf;
	private static ImPreferences instance;
	private  final String CONFIG_PERFER = "im_preferencesdata";
	public ImPreferences(Context context) {
		mCfgPrf = context.getSharedPreferences(CONFIG_PERFER,
				Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE
						| Context.MODE_PRIVATE);
	}
	public static ImPreferences getInstance(Context mContext){
		if(instance == null){
			instance = new ImPreferences(mContext);
		}
		return instance;
	}
	//write boolean
	public  void setPfBoolean(String name,boolean flag) {
		mCfgPrf.edit().putBoolean(name, flag).commit();
	}

	// get boolean
	public  boolean getPfBoolean(String name) {
		return mCfgPrf.getBoolean(name, true);
	}
	//write String
	public  void setPfString(String name,String value) {
		mCfgPrf.edit().putString(name, value).commit();
	}

	// get String
	public  String getPfString(String name) {
		return mCfgPrf.getString(name, null);
	}
	//write int
	public  void setPfInt(String name,int value) {
		mCfgPrf.edit().putInt(name, value).commit();
	}

	// get int
	public  SharedPreferences getCfgPrf() {
		return mCfgPrf;
	}
	
	// get int
	public  int getPfInt(String name) {
		return mCfgPrf.getInt(name, -1);
	}
	//write Long
	public  void setPfLong(String name,long value) {
		mCfgPrf.edit().putLong(name, value).commit();
	}

	// get Long
	public  long getPfLong(String name) {
		return mCfgPrf.getLong(name, -1);
	}
	//write Float
	public  void setPfFloat(String name,float value) {
		mCfgPrf.edit().putFloat(name, value).commit();
	}

	// get Float
	public  float getPfFloat(String name) {
		return mCfgPrf.getFloat(name, -1);
	}
	
}
